﻿using System;
using System.ComponentModel;

namespace Hematology.UserSite.controls
{
	public partial class PageTitle : System.Web.UI.UserControl
	{
		public enum ButtonType
		{
			Hyperlink,
			Button
		}

		public ButtonType TitleButtonType { get; set; }

		public string Text { get; set; }

		public bool ShowButton { get; set; }

		public string ButtonCssClass { get; set; }

		public string ButtonText { get; set; }

		public string ToolTip { get; set; }

		[Bindable(true)]
		public string NavigateUrl { get; set; }

		public event EventHandler ButtonClick;

		protected void Page_Load(object sender, EventArgs e)
		{
			if (ShowButton)
			{
				if (TitleButtonType == ButtonType.Button)
				{
					btnIconAction.Click += ButtonClick;
					btnIconAction.CssClass = ButtonCssClass;
					btnIconAction.Text = ButtonText;
					btnIconAction.ToolTip = ToolTip;

					pnlButton.Visible = true;
				}
				else if (TitleButtonType == ButtonType.Hyperlink)
				{
					if (!String.IsNullOrEmpty(NavigateUrl))
					{
						hlIconAction.NavigateUrl = NavigateUrl;
						hlIconAction.CssClass = ButtonCssClass;
						hlIconAction.Text = ButtonText;
						hlIconAction.ToolTip = ToolTip;

						pnlHyperlink.Visible = true;
					}
				}
			}

			lblText.Text = Text;
		}
	}
}